<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>File Source for fetch_rss.php</title>
	<link rel="stylesheet" type="text/css" href="../media/style.css">
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
	<script src="media/a.js"></script>
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
	<td class="header-top-left"><img src="../media/logo.png" border="0" alt="phpDocumentor " /></td>
    <td class="header-top-right">Examples<br /><div class="header-top-right-subpackage"></div></td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td colspan="2" class="header-menu">
      
                                      
                                    		[ <a href="../classtrees_Examples.html" class="menu">class tree: Examples</a> ]
		[ <a href="../elementindex_Examples.html" class="menu">index: Examples</a> ]
            [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="195" class="menu">
		<div class="package-title">Examples</div>
  <div class="package">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
	</div>
      <b>Packages:</b><br />
  <div class="package">
              <a href="../li_QueryPath.html">QueryPath</a><br />
              <a href="../li_Examples.html">Examples</a><br />
              <a href="../li_Tests.html">Tests</a><br />
      	</div>
      <br />
                        <br />
                      </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file fetch_rss.php</h1>
<p>Documentation is available at <a href="../Examples/_examples---fetch_rss.php.html">fetch_rss.php</a></p>
<div class="src-code"><span class="php">
<ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">&nbsp;*&nbsp;Retrieving&nbsp;remote&nbsp;RSS&nbsp;feeds.</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;This&nbsp;file&nbsp;contains&nbsp;an&nbsp;example&nbsp;of&nbsp;how&nbsp;QueryPath&nbsp;can&nbsp;be&nbsp;used</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*&nbsp;to&nbsp;retrieve&nbsp;and&nbsp;parse&nbsp;a&nbsp;remote&nbsp;RSS&nbsp;feed.&nbsp;If&nbsp;PHP&nbsp;is&nbsp;configured&nbsp;to&nbsp;allow</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc">&nbsp;*&nbsp;HTTP&nbsp;URLs&nbsp;for&nbsp;remote&nbsp;hosts&nbsp;in&nbsp;file&nbsp;manipulation&nbsp;functions,&nbsp;you&nbsp;can&nbsp;use</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-doc">&nbsp;*&nbsp;QueryPath&nbsp;to&nbsp;retrieve&nbsp;the&nbsp;remote&nbsp;file&nbsp;and&nbsp;parse&nbsp;it.</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-doc">&nbsp;*&nbsp;In&nbsp;this&nbsp;example,&nbsp;we&nbsp;grab&nbsp;the&nbsp;RSS&nbsp;feed&nbsp;from&nbsp;remote&nbsp;server&nbsp;and</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-doc">&nbsp;*&nbsp;parse&nbsp;it.&nbsp;From&nbsp;there,&nbsp;we&nbsp;make&nbsp;a&nbsp;list&nbsp;of&nbsp;hyperlinks,&nbsp;one&nbsp;for&nbsp;each&nbsp;item&nbsp;in</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-doc">&nbsp;*&nbsp;the&nbsp;original&nbsp;feed.</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;Examples</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@author</span><span class="src-doc">&nbsp;M&nbsp;Butcher&nbsp;&lt;matt@aleph-null.tv&gt;</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@license</span><span class="src-doc">&nbsp;LGPL&nbsp;The&nbsp;GNU&nbsp;Lesser&nbsp;GPL&nbsp;(LGPL)&nbsp;or&nbsp;an&nbsp;MIT-like&nbsp;license.</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-inc">require_once&nbsp;</span><span class="src-str">'../src/QueryPath/QueryPath.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a19"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-comm">//&nbsp;The&nbsp;URL&nbsp;of&nbsp;the&nbsp;remote&nbsp;RSS&nbsp;feed.</span></div></li>
<li><div class="src-line"><a name="a21"></a><span class="src-var">$remote&nbsp;</span>=&nbsp;<span class="src-str">'http://aleph-null.tv/rss.xml'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a22"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a23"></a><span class="src-comm">//&nbsp;We&nbsp;will&nbsp;write&nbsp;the&nbsp;results&nbsp;into&nbsp;this&nbsp;document.</span></div></li>
<li><div class="src-line"><a name="a24"></a><span class="src-var">$out&nbsp;</span>=&nbsp;<a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'title'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-str">'RSS&nbsp;Titles'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a26"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">top</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a27"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'body'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a28"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;ul/&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a29"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">children</span><span class="src-sym">(</span><span class="src-str">'ul'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a30"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a31"></a><span class="src-comm">//&nbsp;Load&nbsp;the&nbsp;remote&nbsp;document&nbsp;and&nbsp;loop&nbsp;through&nbsp;all&nbsp;of&nbsp;the&nbsp;items.</span></div></li>
<li><div class="src-line"><a name="a32"></a><span class="src-key">foreach&nbsp;</span><span class="src-sym">(</span><a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-var">$remote</span><span class="src-sym">,&nbsp;</span><span class="src-str">'channel&gt;item'</span><span class="src-sym">)&nbsp;</span><span class="src-key">as&nbsp;</span><span class="src-var">$item</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a33"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Get&nbsp;title&nbsp;and&nbsp;link.</span></div></li>
<li><div class="src-line"><a name="a34"></a>&nbsp;&nbsp;<span class="src-var">$title&nbsp;</span>=&nbsp;<span class="src-var">$item</span><span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'title'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a35"></a>&nbsp;&nbsp;<span class="src-var">$link&nbsp;</span>=&nbsp;<span class="src-var">$item</span><span class="src-sym">-&gt;</span><a href="http://www.php.net/next">next</a><span class="src-sym">(</span><span class="src-str">'link'</span><span class="src-sym">)</span><span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a36"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a37"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Do&nbsp;a&nbsp;little&nbsp;string&nbsp;building.</span></div></li>
<li><div class="src-line"><a name="a38"></a>&nbsp;&nbsp;<span class="src-var">$bullet&nbsp;</span>=&nbsp;<span class="src-str">'&lt;li&gt;&lt;a&nbsp;href=&quot;'&nbsp;</span>.&nbsp;<span class="src-var">$link&nbsp;</span>.&nbsp;<span class="src-str">'&quot;&gt;'&nbsp;</span>.&nbsp;<span class="src-var">$title&nbsp;</span>.&nbsp;<span class="src-str">'&lt;/a&gt;&lt;/li&gt;'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a39"></a>&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a40"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;it&nbsp;to&nbsp;the&nbsp;output&nbsp;document.</span></div></li>
<li><div class="src-line"><a name="a41"></a>&nbsp;&nbsp;<span class="src-var">$out</span><span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-var">$bullet</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a42"></a><span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a43"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a44"></a><span class="src-comm">//&nbsp;Write&nbsp;the&nbsp;results.</span></div></li>
<li><div class="src-line"><a name="a45"></a><span class="src-var">$out</span><span class="src-sym">-&gt;</span><span class="src-id">writeHTML</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
</ol>
</span></div>
        <div class="credit">
		    <hr class="separator" />
		    Documentation generated on Thu, 19 Mar 2009 18:01:09 -0500 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.2</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>